<?php


namespace app\index\controller;


use app\common\model\Category as C;
use think\App;
use think\facade\Request;
use think\facade\View;

class Base extends Error
{
    protected $appName;
    protected $controllerName; //获取当前的控制器名
    protected $uid;
    protected $app;
    public function __construct(App $app){
        // 控制器初始化
        $this->initialize();
        $this->nav();
    }
    // 初始化
    protected function initialize(){
        $this->appName        = app('http')->getName();
        $this->controllerName = strtolower(Request::controller());

    }
    public function nav(){
        $catemenu = C::where('parentid',0)->where('status',1)->order('sort asc')->select()->toArray();
        //dump($catemenu);die;
        $view = [
            'controller'=>$this->controllerName,

            'catemenu'=>$catemenu,
            'keywords'=>Request::param('keywords'),
        ];
        View::assign($view);
    }
}